package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"quantization_trading/src/models"
	"quantization_trading/src/server"
	"quantization_trading/src/util"
)



func AddAccount(c *gin.Context)  {
	var data models.Account
	c.ShouldBindJSON(&data)
	code := server.AddAccount(data)
	c.JSON(http.StatusOK,gin.H{
		"status":  code,
		"message": util.GetErrMsg(code),
	})
}

func DelAccount(c *gin.Context)  {
	var data models.Account
	c.ShouldBindJSON(&data)
	code := server.DelAccount(data)
	c.JSON(http.StatusOK,gin.H{
		"status":  code,
		"message": util.GetErrMsg(code),
	})
}

func FindAllAccount(c *gin.Context)  {
	account_list, err := models.FindAllAccount()
	if err !=nil{
		c.JSON(http.StatusOK,gin.H{
			"status":  util.ERROR,
			"message": util.GetErrMsg(util.ADD_ERROR),
		})
	}else {
		c.JSON(http.StatusOK,gin.H{
			"status":  util.SUCCESS,
			"message": account_list,
		})
	}
}